package com.yanchangapp.base;

import com.yanchangapp.model.bean.DailyPlanBean;
import com.yanchangapp.model.bean.GoodsApplyBean;
import com.yanchangapp.model.bean.LookLinkWorkBean;
import com.yanchangapp.model.bean.OrderDetailBean;
import com.yanchangapp.model.bean.POrderCntListBean;
import com.yanchangapp.model.bean.PassApproveBean;
import com.yanchangapp.model.bean.ProductExtractBean;
import com.yanchangapp.model.bean.RecordEmailBean;
import com.yanchangapp.model.bean.Version;
import com.yanchangapp.model.bean.WareHouseBean;
import com.yanchangapp.model.bean.WorkItemBean;
import com.yanchangapp.model.request.SubmitApplyRequest;
import com.yanchangapp.model.response.AllLinkManResponse;
import com.yanchangapp.model.response.ClauseEditResponse;
import com.yanchangapp.model.response.CntListResponse;
import com.yanchangapp.model.response.ContractDetailResponse;
import com.yanchangapp.model.response.ContractListResponse;
import com.yanchangapp.model.response.CreateContractResponse;
import com.yanchangapp.model.response.CreateOrderResponse;
import com.yanchangapp.model.response.EditContractResponse;
import com.yanchangapp.model.response.EditOrderResponse;
import com.yanchangapp.model.response.GoodsApplyResponse;
import com.yanchangapp.model.response.GoodsApproveResponse;
import com.yanchangapp.model.response.HomeBannerResponse;
import com.yanchangapp.model.response.LoginResponse;
import com.yanchangapp.model.response.MailDetailResponse;
import com.yanchangapp.model.response.MailListResponse;
import com.yanchangapp.model.response.MailUnreadResponse;
import com.yanchangapp.model.response.MenuResponse;
import com.yanchangapp.model.response.MgDailyListResponse;
import com.yanchangapp.model.response.MsgContentResponse;
import com.yanchangapp.model.response.OperateBookResponse;
import com.yanchangapp.model.response.PlanDetailResponse;
import com.yanchangapp.model.response.PsListResponse;
import com.yanchangapp.model.response.RecordDetailResponse;
import com.yanchangapp.model.response.RecordListResponse;
import com.yanchangapp.model.response.RelatedManResponse;
import com.yanchangapp.model.response.SupplierListResponse;
import com.yanchangapp.model.response.UpdateRecordResponse;
import com.yanchangapp.model.response.WaitDoneResponse;
import com.yanchangapp.model.response.WorkItemDetailResponse;
import com.zxl.baselib.bean.response.BaseListResponse;
import com.zxl.baselib.bean.response.BasePageListResponse;
import com.zxl.baselib.bean.response.BaseResponse;

import java.util.List;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;

import static com.yanchangapp.commom.AppConstant.IS_TESTING;

/**
 * @author crazyZhangxl on 2018/11/1.
 * Describe:
 */
public interface MyApi {
    //"http://192.168.1.23:8100/"  https://ftpuat.wjsci.com:8100/
    // https://oa.wjsci.com:8100/
//    String BASE_URL = "https://ftpuat.wjsci.com:8100/";

//    String BASE_URL = "http://192.168.1.23:8100/";
//    String BASE_WEB_URL = "http://192.168.1.23:8100/";
//
//    String BASE_URL = "https://ftpuat.wjsci.com:8100/";
//    String BASE_WEB_URL = "https://appuat.wjsci.com/#";

    String BASE_URL = "https://oa.wjsci.com:8100/";
    String BASE_WEB_URL = "https://app.wjsci.com/#";


    // ============================= 基础信息相关 开始 ==============================


    @GET("base/terminal/selectLastVersion/1")
    Observable<BaseResponse<Version>> checkUpdate();


    /**
     * 登录
     * @param account
     * @param password
     * @return
     */
    @GET("login/a/{account}/{password}")
    Observable<LoginResponse> requestLogin(
            @Path("account") String account,
            @Path("password") String password
    );

    /**
     * 注册
     * @param body
     * @return
     */
    @POST("register")
    Observable<BaseResponse> requestRegister(@Body RequestBody body);

    /**
     * 修改密码
     * @param body
     * @return
     */
    @PUT("base/user/updatePassword")
    Observable<BaseResponse> updatePassword(@Body RequestBody body);


    @PUT("forgetPassword")
    Observable<BaseResponse> forgetPassword(@Body RequestBody body);

    /**
     * 获取验证码
     * @param body
     * @return
     */
    @POST("sms")
    Observable<BaseResponse> querySmsCode(@Body RequestBody body);

    /**
     * 更新手机号码
     * @param body
     * @return
     */
    @PUT("base/user/updateMobile")
    Observable<BaseResponse> updateMobile(@Body RequestBody body);


    @GET("base/chart/getChartList")
    Observable<HomeBannerResponse> queryBanner();

    @GET("base/user/getFirstPageCountMobile")
    Observable<WaitDoneResponse> queryWaitDoneList();

    @GET("base/employee/getAuthorityMobile/{id}")
    Observable<MenuResponse> queryMenuLists(@Path("id") int userID);

    // ============================= 基础信息相关结束 ==============================



    // ============================= 消息列表 开始 ==============================

    /**
     * 获取消息列表...
     * 传入不同的类型即可...
     * @param body
     * @return
     */
    @POST("base/message/getMessageList")
    Observable<MsgContentResponse> queryMessageList(@Body RequestBody body);

    /**
     * 设置消息已读...
     * @param body
     * @return
     */
    @POST("base/message/updateBatchMessage")
    Observable<BaseResponse> setReadedMessageList(@Body RequestBody body);

    // ============================= 消息列表 结束 ==============================


    // ============================= 邮件 开始 ==============================
    /**
     * 分页查询邮件信息...
     * @param mailType
     * @param body
     * @return
     */
    @POST("mail/info/{mailType}")
    Observable<MailListResponse> queryMailListInfo(@Path("mailType") String mailType,
                                                   @Body RequestBody body);

    /**
     * 获取邮件详情信息
     * @param mailID
     * @return
     */
    @GET("mail/info/{mailID}")
    Observable<MailDetailResponse> queryMailDetailInfo(@Path("mailID") int mailID);

    /**
     * 将特定的邮件移动到目标的邮件中...
     * @param body
     * @return
     */
    @PUT("mail/info/shift/{mailType}")
    Observable<BaseResponse> moveMailsToTargetMails(@Path("mailType") String mailType,
                                                     @Body List<Integer> body);


    @PUT("mail/info/seen/{mailSeen}")
    Observable<BaseResponse> setMailSeenState(@Path("mailSeen") int mailSeen,
                                              @Body List<Integer> body);

    @GET("mail/info/counts")
    Observable<MailUnreadResponse> getUnReadCount();

    /**
     * 彻底删除接口
     * 解决Delete无法传递Body的问题
     * @param body
     * @return
     */
    @HTTP(method = "DELETE",path = "mail/info/mails",hasBody = true)
    Observable<BaseResponse> actualDeleteMail(@Body List<Integer> body);

    /**
     * 发送邮件
     * @param body
     * @return
     */
    @POST("mail/info/dispatch")
    Observable<BaseResponse> sendMail(@Body RequestBody body);


    @POST("mail/info/dispatch")
    Observable<BaseResponse> sendTotalMail(@Body RequestBody body);


    /**
     * 存草稿或者/或者修改草稿的功能
     * @param body
     * @return
     */
    @POST("mail/info/storage")
    Observable<BaseResponse> saveMailToDraft(@Body RequestBody body);

    /**
     *
     * @param companyId
     * @return
     */
    @GET("base/company/getStructureAndAddressBook/{companyId}")
    Observable<CntListResponse> queryMailContacts(@Path("companyId") int companyId);

    // ============================= 邮件 结束 ==============================



    // ============================= 我的管理 开始 ==============================

    /**
     *
     * 查询个人今日计划列表
     *
     * @param employeeId 员工ID
     * @return
     */
    @POST("plan/work/getPersonalWorkList/{employeeId}")
    Observable<MgDailyListResponse> queryDailyPlanLists(@Path("employeeId") int employeeId,@Body RequestBody body);


    /**
     * 开始个人计划
     * @param planId
     * @return
     */
    @GET("plan/work/startWork/{planId}")
    Observable<BaseResponse> startWorkPlan(@Path("planId") int planId);


    /**
     * 取消个人计划
     * @param planId
     * @return
     */
    @GET("plan/work/cancelWork/{planId}")
    Observable<BaseResponse> cancelWorkPlan(@Path("planId") int planId);


    /**
     * 延期个人计划
     * @param planId 计划ID
     * @param body  延期的请求体
     * @return
     */
    @POST("plan/work/delayWork/{planId}")
    Observable<BaseResponse> delayWorkPlan(@Path("planId") int planId,@Body RequestBody body);


    // ============================= 我的管理 结束 ==============================



    // ============================= 采购 开始 ==============================

    // ---- 订单相关... ----
    /**
     * 依据公司ID获取采购订单列表
     * @param companyId
     * @param body
     * @return
     */
    @POST("purchase/order/byCompany/{companyId}")
    Observable<PsListResponse> queryPurchaseList(@Path("companyId") int companyId, @Body RequestBody body);


    /**
     *  获取合同列表
      * @param companyId
     * @param body
     * @return
     */
    @POST("purchase/contract/available/byCompany/{companyId}")
    Observable<BaseListResponse<POrderCntListBean>> queryCmyContractList(@Path("companyId") int companyId,
                                                                         @Body RequestBody body);

    /**
     * 根据合同ID  ==>  获取产品列表
     * @param contractId
     * @param body
     * @return
     */
    @POST("purchase/contract/product/{contractId}")
    Observable<BaseListResponse<ProductExtractBean>> queryProductExtractList(
            @Path("contractId") String contractId,@Body RequestBody body
    );

    @POST("purchase/product/bySupplyCo/{supplierId}")
    Observable<BaseListResponse<ProductExtractBean>> querySupplierProductList(@Path("supplierId") String supplierId,@Body RequestBody body);

    /**
     * 依据订单ID获取订单详情信息....
     * @param orderId
     * @return
     */
    @GET("purchase/order/{orderId}")
    Observable<BaseResponse<OrderDetailBean>> getPurchaseOrderDetail(@Path("orderId") String orderId);

    /**
     * 根据订单ID删除订单... ==> 作废订单
     * @param orderId
     * @return
     */
    @DELETE("purchase/order/{orderId}")
    Observable<BaseResponse> deleteOrderById(@Path("orderId") String orderId);


    @PUT("purchase/order")
    Observable<EditOrderResponse> putEditOrder(@Body RequestBody body);

    /**
     * 根据订单ID进行提交审批
     * @param orderId
     * @return
     */
    @POST("purchase/order/{orderId}/submission")
    Observable<BaseResponse> submitApprovalOrderByID(@Path("orderId") String orderId);

    /**
     * 创建订单
     * @param body
     * @return
     */
    @POST("purchase/order/generate")
    Observable<CreateOrderResponse> createOrder(@Body RequestBody body);


    /**
     * 获取委托企业下所有的仓库地址
     * @return
     */
    @POST("purchase/order/3rdCompany/warehouse")
    Observable<BaseListResponse<WareHouseBean>> queryAllWareHouse();

    /**
     * 获取供应商列表
     * @param body
     * @return
     */
    @POST("purchase/supplyCo/byCompany/{companyId}")
    Observable<SupplierListResponse> querySupperLists(@Path("companyId") int companyId,@Body RequestBody body);


    // ------- 合同 ------

    /**
     * 根据状态获取合同列表信息
     * @param companyId
     * @param body
     * @return
     */
    @POST("purchase/contract/byCompany/{companyId}")
    Observable<ContractListResponse> queryContractsList(@Path("companyId") int companyId, @Body RequestBody body);

    /**
     * 获取合同详情...
     * @param id
     * @return
     */
    @GET("purchase/contract/{id}")
    Observable<BaseResponse<ContractDetailResponse>> getContractDetail(@Path("id") String id);


    /**
     * 获取默认的合同条款信息
     * @return
     */
    @GET("purchase/contract/clause")
    Observable<ClauseEditResponse> queryDefaultClause();


    /**
     * 新建合同
     * @param body
     * @return
     */
    @POST("purchase/contract/generate")
    Observable<CreateContractResponse> createContract(@Body RequestBody body);

    /**
     * 修改合同
     * @param body
     * @return
     */
    @PUT("purchase/contract")
    Observable<EditContractResponse> editContract(@Body RequestBody body);


    /**
     * 根据订单ID进行提交审批
     * @param contractId
     * @return
     */
    @POST("purchase/contract/{contractId}/submission")
    Observable<BaseResponse> submitApprovalContractByID(@Path("contractId") String contractId);

    /**
     * 根据公司ID获取经营品种列表
     * @param companyId
     * @param body
     * @return
     */
    @POST("purchase/product/byCompany/{companyId}")
    Observable<GoodsApplyResponse> queryApplyGoodsList(@Path("companyId") int companyId,@Body RequestBody body);

    /**
     * 根据产品ID获取经营品种详细信息
     * @param id
     * @return
     */
    @GET("purchase/product/getDetail/{id}/{isThirdFlag}")
    Observable<BaseResponse<GoodsApplyBean>> queryApplyDetail(@Path("id") String id,@Path("isThirdFlag") int isThirdFlag);


    /**
     * 养护产品提交审批
     * @param submitApplyRequests
     * @return
     */
    @POST("purchase/record/saveRecord")
    Observable<BaseResponse> submitGoodsApply(@Body List<SubmitApplyRequest> submitApplyRequests);


    /**
     * 分页获取采购记录列表信息  ok
     * @param body
     * @return
     */
    @POST("purchase/record/getRecordList")
    Observable<RecordListResponse> queryRecordList(@Body RequestBody body);

    /**
     * 获取审批记录详情信息
     *
     * 该接口包含待审批 + 已审批
     * @param id
     * @param body
     * @return
     */
    @POST("purchase/record/getRecordById/{id}")
    Observable<BaseResponse<RecordDetailResponse>> queryRecordDetail(@Path("id") int id,
                                                       @Body RequestBody body);

    /**
     * 获取采购审批列表信息
     * @param body
     * @return
     */
    @POST("purchase/record/getExamineRecordList")
    Observable<GoodsApproveResponse> queryApproveList(@Body RequestBody body);


    /**
     * 通过订单ID去查询审批详情页面...
     * @param orderId
     * @return
     */
    @GET("purchase/record/getOrders/{orderId}")
    Observable<BaseResponse<PassApproveBean>> queryAvDetailByOrderId(@Path("orderId") String orderId);


    /**
     * 将特定订单号的进行提交审批
     * @param id
     * @param body
     * @return
     */
    @PUT("purchase/record/updateRecordStatus/{id}")
    Observable<BaseResponse> submitRecordByID(@Path("id") int id,@Body RequestBody body);

    /**
     * 进行删除
     * @param id
     * @return
     */
    @DELETE("purchase/record/deleteRecord/{id}")
    Observable<BaseResponse> deleteRecordByID(@Path("id") int id);
    /**
     * 通过传递订单ID 采购数量 以及供应商ID 进行更新商品
     * @param body
     * @return
     */
    @PUT("purchase/record/updateRecord")
    Observable<UpdateRecordResponse> updateRecordProduct(@Body RequestBody body);

    /**
     * 驳回丁丁
     * @param body
     * @return
     */
    @POST("purchase/record/rejectRecord")
    Observable<BaseResponse> rejectRecord(@Body RequestBody body);

    @GET("purchase/record/adoptRecord/{id}")
    Observable<BaseResponse> passRecord(@Path("id") int id);

    @GET("purchase/record/getMailContent/{id}")
    Observable<BaseListResponse<RecordEmailBean>> queryMailContent(@Path("id") int id);

    // ============================= 采购 结束 ==============================


    // ============================= 我的管理 新需求 开始 ==============================

    /**
     * 分页查询工作项
     * @param body
     * @return
     */
    @POST("manage/app/workItem/getMyWorkItemList")
    Observable<BasePageListResponse<WorkItemBean>> postQueryWorkItemList(@Body RequestBody body);
    /**
     * 根据工作项ID去查询工作项详情...
     * @param id
     * @return
     */
    @GET("manage/app/workItem/getWorkItemById/{id}")
    Observable<BaseResponse<WorkItemDetailResponse>> getQueryWorkItemDetail(@Path("id") long id);


    /**
     * 生成今日计划
     * @param body
     * @return
     */
    @POST("manage/app/schedule/addTodaySchedule")
    Observable<BaseResponse> postMakeDailyPlan(@Body RequestBody body);

    /**
     * 为特定关联员工生成计划....
      * @param body
     * @return
     */
    @POST("manage/app/schedule/addTodayScheduleForRelatedEmployeeOne")
    Observable<BaseResponse> postMakePlanFromMan(@Body RequestBody body);

    /**
     * 为特定工作项生成计划....
     * @param body
     * @return
     */
    @POST("manage/app/schedule/addTodayScheduleForRelatedEmployeeTwo")
    Observable<BaseResponse> postMakePlanFromWork(@Body RequestBody body);

    /**
     * 通过计划ID获取任务书详情信息
     * @param id
     * @return
     */
    @GET("manage/app/schedule/getOperationByScheduleId/{id}")
    Observable<BaseResponse<OperateBookResponse>> getOperateDetail(@Path("id") long id);

    /**
     * 通过计划ID 开始计划
     * @param id
     * @return
     */
    @PUT("manage/app/schedule/startScheduleById/{id}")
    Observable<BaseResponse> putStartPlan(@Path("id") long id);


    /**
     * 通过计划ID 完成计划,携带评语信息..
     * @param id
     * @param body
     * @return
     */
    @PUT("manage/app/schedule/finishScheduleById/{id}")
    Observable<BaseResponse> putFinishPlan(@Path("id") long id,@Body RequestBody body);

    /**
     * 通过计划ID 不能完成计划
     * @param id
     * @param body
     * @return
     */
    @PUT("manage/app/schedule/incompleteScheduleById/{id}")
    Observable<BaseResponse> putCannotFinishPlan(@Path("id") long id,@Body RequestBody body);

    /**
     * 通过计划ID 更新个人计划
     * @param id
     * @param body
     * @return
     */
    @PUT("manage/app/schedule/updateSchedule/{id}")
    Observable<BaseResponse> putUpdateFinishPlan(@Path("id") long id,@Body RequestBody body);

    /**
     * 通过计划ID获取计划详情信息
     * @param id
     * @return
     */
    @GET("manage/app/schedule/getScheduleById/{id}")
    Observable<BaseResponse<PlanDetailResponse>> getQueryPlanDetail(@Path("id") long id);


    /**
     * post请求查询历史计划列表
     * @param body
     * @return
     */
    @POST("manage/app/schedule/getHistoryScheduleListVersion2")
    Observable<BasePageListResponse<DailyPlanBean>> postQueryHistoryPlans(@Body RequestBody body);

    /**
     * get 查询今日计划...
     * @param body
     * @return
     */
    @POST("manage/app/schedule/getTodayScheduleList")
    Observable<BasePageListResponse<DailyPlanBean>> postQueryDailyPlans(@Body RequestBody body);


    /**
     * 根据工作项ID获取关联员工
     * @param id
     * @return
     */
    @GET("manage/app/workItem/getRelatedEmployeeList/{id}")
    Observable<BaseListResponse<RelatedManResponse>> getQueryLookMan(@Path("id") long id);

    /**
     *      查看 关联工作项
     * @return
     */
    @POST("manage/app/workItem/getRelatedWorkItemList/{id}")
    Observable<BaseListResponse<LookLinkWorkBean>> getQueryLookWorkItem(@Path("id") long id,@Body RequestBody requestBody);



    /**
     * 获取关联员工列表...
     * @return
     */
    @POST("manage/app/workItem/getRelatedEmployeeListForApp")
    Observable<BaseListResponse<AllLinkManResponse>> getQueryAllLinkMan(@Body RequestBody body);



    // ============================= 我的管理 新需求 结束 ==============================

}
